<!--审核详情-->
<template>
  <div class='home'>
    <!--头部提示-->
    <el-row>
      <el-col :span="12"><div class="grid-content bg-purple-light" style="margin-top: 10px;">
        <h4 class="wf_h">审核详情</h4>
      </div>
      </el-col>
    </el-row>
    <!--数据展示-->
    <el-table
      :data="tableData"
      size="mini"
      style="width: 100%">
      <el-table-column prop="taskDisplayName" label="任务名"></el-table-column>
      <el-table-column prop="showResult" label="审核结果"></el-table-column>
      <el-table-column prop="opinion" label="审核意见"></el-table-column>
      <el-table-column prop="approvalDatetime" label="审核时间"></el-table-column>
    </el-table>
  </div>
</template>

<script>
  /* ajax请求 */
  import * as kk from '@/utils/k-utils'

  export default {
    name: 'ApprovalDetail',
    props: {
      // 保存列表页面传过来的数据，子组件接受父组件数据
      param: {
        type: Object,
        required: true
      }
    },
    data() {
      return {
        tableData: [],
        first: true
      }
    },
    // 执行一次，且第一次执行
    mounted() {
      this.init()
      this.first = true
    },
    // 组件被激活，第一次不执行
    activated() {
      // this.param父组件改变该属性值
      if (this.first) {
        this.first = false
        return
      }
      // 刷新数据
      this.search(this.param)
    },
    methods: {
      init() {
        // 刷新数据
        this.search(this.param)
      },
      // 刷新表格数据
      search(requestSupportParams) {
        var _this = this
        // 加载审核详情列表
        var url = '/approval/getApprovalDetail.json?approvalId=' + requestSupportParams.approvalId
        kk.k_load_url('workflow', url, {}).then(rep => {
          rep = JSON.parse(rep)
          if (rep.status === '500') {
            _this.$message(rep.message)
          } else {
            var result = rep.data
            result.showResult = result.resultText || window.processStatus[result.result]
            result.approvalDatetime = kk.dateFormat(result.approvalDate) + ' ' + kk.timeFormat(result.approvalTime)
            // 添加数据，每次打开页面都不同
            _this.tableData = [result]
          }
        })
      }
    }
  }
</script>

<style scoped>
  /*让文本可以被选中*/
  .home {
    -moz-user-select: text; /*火狐*/
    -webkit-user-select: text; /*webkit浏览器*/
    -ms-user-select: text; /*IE10*/
    -khtml-user-select: text; /*早期浏览器*/
    user-select: text;
  }
  .wf_h {
    font-size: 18px;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.1;
    color: inherit;
  }
</style>
